package com.gs.demo.enums;

/**
 * 服务商权益内容
 *
 * @author zhouwb
 * @createdate 2019年8月22日
 */
public enum ResultCodeEnum {
    SYSTEM(101, "系统异常"),
    SUCCESS(200, "操作成功"),
    VALID(201, "参数校验错误"),//业务异常都以2xx开头
	FILE_SIZE(301, "超过上传文件最大值"),//文件类3xx开头
    UNDEFINED(999, "");

    private Integer value;
    private String text;

    private ResultCodeEnum(Integer value, String text) {
        this.value = value;
        this.text = text;
    }

    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

    public static ResultCodeEnum parse(Integer value) {
        for (ResultCodeEnum e : ResultCodeEnum.values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return ResultCodeEnum.UNDEFINED;
    }

    public static ResultCodeEnum parseText(String text) {
        for (ResultCodeEnum e : ResultCodeEnum.values()) {
            if (e.text.equals(text)) {
                return e;
            }
        }
        return ResultCodeEnum.UNDEFINED;
    }
}
